﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SimpleExpression;
using System.Data;

namespace SimpleExpression
{
    public abstract class Expression
    {
        public abstract void Accept(ExpressionVisitor visitor);

        protected string AddParameter(IDbCommand command, object value)
        {
            IDbDataParameter parameter = command.CreateParameter();

            parameter.ParameterName = string.Format("@p{0}", command.Parameters.Count);
            parameter.Value = value;

            command.Parameters.Add(parameter);

            return parameter.ParameterName;
        }
    }
}
